package com.ldk.base.framework.util.sms;

/**
 * 短信工厂
 *
 * @author xiangwl
 */
public class SmsFactory {

    /**
     * 发送短信
     *
     * @param config
     * @return
     */
    public static Boolean send(SmsConfig config) {
        if (config == null) return false;
        ISmsApi smsApi = null;
        if (config.getPlatform() == SmsPlatform.JXT) {
            smsApi = new JxtSmsApi();
        } else if (config.getPlatform() == SmsPlatform.Bechtech) {
            smsApi = new BechtechSms();
        } else if (config.getPlatform() == SmsPlatform.Yun) {
            smsApi = new Sms();
        } else if (config.getPlatform() == SmsPlatform.AliDayu) {
            smsApi = new AliDayu();
        } else if (config.getPlatform() == SmsPlatform.Huyi) {
            smsApi = new HuyiSmsApi();
        }
        if (smsApi != null)
            return smsApi.send(config);
        return false;
    }

    /**
     * 发送短信
     *
     * @param smsApi 自定义的短信平台API
     * @param config 自定义的短信发送平台配置
     * @return
     */
    public static Boolean send(ISmsApi smsApi, SmsConfig config) {
        if (smsApi == null || config == null) return false;
        return smsApi.send(config);
    }
}
